<template>
  <div class="checkCourseArrangement">
    <el-breadcrumb separator="/" class="breadcrumb-bottom">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>课程管理</el-breadcrumb-item>
      <el-breadcrumb-item>查看排课结果</el-breadcrumb-item>
    </el-breadcrumb>
<el-table
      :data="courseInfo"
      style="width: 100%"
      :default-sort="{prop: 'teacherName',order:'ascending'}">
      <el-table-column
        prop="teacherName"
        label="任课老师"
        min-width="120"
        sortable>
      </el-table-column>
      <el-table-column
        prop="teacherID"
        label="教师编号"
        min-width="120"
        sortable>
      </el-table-column>
      <el-table-column
        prop="positionalTitle"
        label="教师职称"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="courseID"
        label="课程编号"
        min-width="120"
        sortable>
      </el-table-column>
      <el-table-column
        prop="courseNameCN"
        label="所任课程"
        min-width="140">
      </el-table-column>
      <el-table-column
        prop="class"
        label="所任班级"
        min-width="130">
      </el-table-column>
      <el-table-column
        prop="weeks"
        label="上课周数"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="weeklyHour"
        label="周学时数"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="isUse"
        label="是否使用多媒体"
        min-width="150">
      </el-table-column>
    </el-table>
    <el-row :gutter="20" style="margin: 20px 0 0 0">
      <el-col :span="10" :offset="7">
        <el-input type="textarea" v-model="form.checkOpinion" :rows="5" placeholder="请输入审核意见："></el-input>
      </el-col>
    </el-row>
    <el-row :gutter="20" style="margin: 150px 0 0 0">
      <el-col :span="6" :offset="7">
        <el-button type="info" class="add-pd-26" @click="submitAgreement">同&nbsp;&nbsp;&nbsp;意</el-button>
      </el-col>
      <el-col :span="6" >
        <el-button type="info" class="add-pd-26" @click="submitDisagreement">不同意</el-button>
      </el-col>
    </el-row>
    
  </div>
</template>

<script>
  export default {
    name: 'checkCourseArrangement',
    data() {
      return {
        courseInfo: [],
        form:{
        	checkOpinion:'',
        	isCheck:'',
        	coursesArrangeID:''
        }
      }
    },
    created () {
		this.res();
    },
    methods: {
      res: function () {
      	var coursesArrangeID = this.$route.query.coursesArrangeID;
      	alert(coursesArrangeID);
        this.$http.post(`http://localhost:8080/TeachingMIS/courseArrange/getCourseArrList`, {coursesArrangeID:coursesArrangeID}).then((res) => {
		          // 响应成功回调
		          console.log(res.body)
		          this.courseInfo = res.body.arrangeList;
		        }, (err) => {
		          // 响应错误回调
		          console.log("服务器异常！");
		        })

      },
      submitAgreement(){
      	 this.form.isCheck = "通过";
      	 this.form.coursesArrangeID = this.$route.query.coursesArrangeID;
		 this.$http.post(`http://localhost:8080/TeachingMIS/courseArrange/arrangeAgree`, this.form).then((res) => {
		          // 响应成功回调
		          console.log(res.body)
		          this.courseInfo = res.body.arrangeList;
		        }, (err) => {
		          // 响应错误回调
		          console.log("服务器异常！");
		        })
      },
      submitDisagreement(){
      	 if (this.form.checkOpinion === '') {
            alert("请输入审核意见!");
        } else {
         this.form.isCheck = "通过";
         this.form.coursesArrangeID = this.$route.query.coursesArrangeID;
		 this.$http.post(`http://localhost:8080/TeachingMIS/courseArrange/arrangeDisAgree`, this.form).then((res) => {
		          // 响应成功回调
		          console.log(res.body)
		          this.courseInfo = res.body.arrangeList;
		        }, (err) => {
		          // 响应错误回调
		          console.log("服务器异常！");
		        })
        }
		 
      },
      submit(){
        this.$router.replace({path: 'CourseExamination'});
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .add-pd-26 {
    padding-left: 1.6em;
    padding-right: 1.6em;
  }
</style>
